#include "sfsis.h"
#include "helper.h"
static OutAnimation_Types currentOutAnimationType = OUT_ANIMATION_FADE;

/*渐变效果*/
static Helper_EaseInEaseOut_Context easeOutContext = {.key = 0, .target = 0};

void outAnimationFade_Restart(void)
{
    easeOutContext.key = 0xFF;
}

Efct_Stage outAnimationFade(void)
{
    su16 tmp = 0;
    helper_easeInEaseOutGenerate(&easeOutContext);
    for (tmp = 0; tmp < gCfgFactoryPtr->enabledDotNumber; tmp++)
    {
        rgbStrip.rgbMemory[tmp][0] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][0], easeOutContext.key);
        rgbStrip.rgbMemory[tmp][1] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][1], easeOutContext.key);
        rgbStrip.rgbMemory[tmp][2] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][2], easeOutContext.key);
    }
    if (easeOutContext.key == easeOutContext.target)
    {
        return E_FINISHED;
    }
    else
    {
        return E_PROCESS;
    }
}

void outAnimationRestart(OutAnimation_Types outType)
{
    currentOutAnimationType = outType;
    switch (outType)
    {
    case OUT_ANIMATION_FADE:
        outAnimationFade_Restart();
        break;
    default:
        break;
    }
}
Efct_Stage outAnimation(void)
{
    Efct_Stage ret = E_FINISHED;
    switch (currentOutAnimationType)
    {
    case OUT_ANIMATION_FADE:
        ret = outAnimationFade();
        break;
    default:
        ret = outAnimationFade();
        break;
    }
    return ret;
}